package com.kugong;


import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;

/**
 * Created by Administrator on 2015/8/4.
 */
public class GlobalActionInterceptor implements Interceptor {
    @Override
    public void intercept(Invocation invocation) {
        try {
            String name = invocation.getController().getSessionAttr("name");
            if((name==null||"".equals(name.trim()))&&!(invocation.getControllerKey().indexOf("weixin")>-1)){
                invocation.getController().redirect("/");
            }else{
                invocation.invoke();
            }

        }catch (Exception e){
            e.printStackTrace();
            invocation.getController().render("/view/common/e.jsp");
        }


    }
}
